"""
-------------------------------
- File_Name: __init__.py.py
- Date: 2025/2/17
- Author: yangzhide
- Email: xxzjyzd@126.com
- Description: 注册中间件
-------------------------------
"""

from starlette.middleware import Middleware
from starlette.middleware.cors import CORSMiddleware
from app.middlewares.logs import APILoggerMiddleware, APILoggerAddResponseMiddleware, BackGroundTaskMiddleware


def register_middleware():
    middleware = [
        Middleware(
            CORSMiddleware,
            allow_origins=["*"],
            allow_credentials=True,
            allow_methods=["*"],
            allow_headers=["*"],
        ),
        # Middleware(BackGroundTaskMiddleware),
        Middleware(APILoggerMiddleware),
        Middleware(APILoggerAddResponseMiddleware),

    ]

    return middleware


